class TemplatePartsController < ApplicationController
  # GET /template_parts
  # GET /template_parts.xml
  layout "backend"
  def index
    @template_parts = TemplatePart.find(:all)
  end

  # GET /template_parts/1
  # GET /template_parts/1.xml
  def show
    @template_part = TemplatePart.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @template_part }
    end
  end

  # GET /template_parts/new
  # GET /template_parts/new.xml
  def new
    @template_part = TemplatePart.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @template_part }
    end
  end

  # GET /template_parts/1/edit
  def edit
    @template_part = TemplatePart.find(params[:id])
  end

  # POST /template_parts
  # POST /template_parts.xml
  def create
    @template_part = TemplatePart.new(params[:template_part])

    respond_to do |format|
      if @template_part.save
        flash[:notice] = 'TemplatePart was successfully created.'
        format.html { redirect_to(@template_part) }
        format.xml  { render :xml => @template_part, :status => :created, :location => @template_part }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @template_part.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /template_parts/1
  # PUT /template_parts/1.xml
  def update
    @template_part = TemplatePart.find(params[:id])

    respond_to do |format|
      if @template_part.update_attributes(params[:template_part])
        flash[:notice] = 'TemplatePart was successfully updated.'
        format.html { redirect_to(@template_part) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @template_part.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /template_parts/1
  # DELETE /template_parts/1.xml
  def destroy
    @template_part = TemplatePart.find(params[:id])
    @template_part.destroy

    respond_to do |format|
      format.html { redirect_to(template_parts_url) }
      format.xml  { head :ok }
    end
  end
end
